package com.tdwyz.fictionmanage.service;

import com.tdwyz.fictionmanage.mapper.FictionCategoryMapper;
import com.tdwyz.fictionmanage.pojo.FictionCategory;
import com.tdwyz.fictionmanage.pojo.Result;
import com.tdwyz.fictionmanage.utils.ThreadLocalUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FictionCategoryService {

    @Resource
    private FictionCategoryMapper fictionCategoryMapper;

    public boolean add(String categoryName, String categoryAlias, int id) {

        return fictionCategoryMapper.add(categoryName,categoryAlias,id);

    }

    public List<FictionCategory> get() {
        int id = ThreadLocalUtil.getUserId();
        return fictionCategoryMapper.get(id);
    }

    public FictionCategory getCategoryById(Integer id) {
        return fictionCategoryMapper.getCategoryById(id);
    }

    public Boolean delete(Integer id) {
        return fictionCategoryMapper.delete(id);
    }

    public boolean update(FictionCategory fictionCategory) {
        return fictionCategoryMapper.update(fictionCategory);
    }

    public List<FictionCategory> getall() {
        return fictionCategoryMapper.getall();
    }
}
